chcp 65001
@echo off
echo npm-run-dev

rem 线上常量
set REMOTE_URL=https://gitee.com/示例仓库

rem 本地常量
set PORJECT_DIR=D:\WWW
set PORJECT_NAME=示例仓库
set PORJECT_FULL=%PORJECT_DIR%\%PORJECT_NAME%
set MY_BRANCH=lwq
set DEV_BRANCH=dev

echo 1、初始化git
if not exist "%PORJECT_FULL%\.git" (cd /d %PORJECT_DIR% && git clone %REMOTE_URL% %PORJECT_NAME%)

echo 2、拉取最新代码
if not exist "%PORJECT_FULL%\.git\refs\heads\%MY_BRANCH%" (cd /d %PORJECT_FULL% && git branch %MY_BRANCH%)
if not exist "%PORJECT_FULL%\.git\refs\heads\%DEV_BRANCH%" (cd /d %PORJECT_FULL% && git branch %DEV_BRANCH%)
cd /d %PORJECT_FULL% && git checkout %DEV_BRANCH% && git pull origin %DEV_BRANCH% && git checkout %MY_BRANCH% && git merge %DEV_BRANCH%

echo 3、npm启动
if not exist "%PORJECT_FULL%\node_modules" (cd /d %PORJECT_FULL% && npm install && npm run dev) else (cd /d %PORJECT_FULL% && npm update && npm run dev)

pause